<?php
class Bliss_Media_Compressor_Stylesheet
{
	protected $_method;
	protected $_contents;
	
	public function __construct($contents, $type='simple')
	{
		$this->_contents = $contents;
		$this->_method = "_compress".ucwords($type);
		if(!method_exists($this, $this->_method)) {
			throw new Model_Media_Exception("Stylesheet compressor type '{$type}' does not exist.");
		}
	}
	
	public function compress()
	{
		return call_user_func(array($this, $this->_method), $this->_contents);
	}
	
	protected function _compressSimple($contents)
	{
		$contents = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $contents);
    	$contents = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $contents);
		return $contents;
	}
}
?>